package me.softwareengineer.guice.rendering.domain;

import java.util.List;

import me.softwareengineer.guice.rendering.listener.EndDefinitionTermEvent;
import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.StartDefinitionTermEvent;

/**
 * Represents a definition term. A definition term is the header of definition list.
 * For instance, the Wiki syntax is:
 * 
 * <code>
 * <pre>
 *       ; definition term
 *       : first definition
 *       : second definition
 *       ; another definition term
 *       : first definition
 *       : second definition
 * </pre>
 * </code>
 * 
 * <p>
 * This class produces the following events:
 * <ul>
 * <li>{@link StartDefinitionTermEvent}</li>
 * <li>{@link EndDefinitionTermEvent}}</li>
 * </ul>
 * </p>
 * 
 * <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 * 
 * @author yad.tahir
 * @since 1.0
 * @see DefinitionListElement
 * @see StartDefinitionTermEvent
 * @see EndDefinitionTermEvent
 * @see #render(Listener)
 * @see Element
 */
public final class DefinitionTermElement extends Element {

	/**
	 * Creates a definition term element without properties
	 * 
	 * @param children
	 *            the children of the element
	 */
	public DefinitionTermElement(List<Element> children) {
		super(children);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * This method produces the following event:
	 * <ul>
	 * <li>
	 * 		{@link EndDefinitionTermEvent}
	 * </li>
	 * </ul>
	 * 
	 * @see EndDefinitionTermEvent
	 */
	@Override
	public void afterElement(Listener listener) {
		EndDefinitionTermEvent e = new EndDefinitionTermEvent();
		listener.onEvent(e);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * This method produces the following event:
	 * <ul>
	 * <li>
	 * 		{@link StartDefinitionTermEvent}
	 * </li>
	 * </ul>
	 * 
	 * @see StartDefinitionTermEvent
	 */
	@Override
	public void beforeElement(Listener listener) {
		StartDefinitionTermEvent e = new StartDefinitionTermEvent();
		listener.onEvent(e);
	}
}
